<!DOCTYPE html>
<html ng-app="app">
<head lang="en">
    <meta charset="UTF-8">
    <title>ng-echarts test</title>
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.min.css" />
    <link rel="stylesheet" href="app.css"/>
</head>
<body ng-controller="MainCtrl">

<ng-echarts class="col-md-6" style="height: 400px;" setting="setting"></ng-echarts>

<script src="http://cdn.bootcss.com/echarts/2.2.7/echarts-all.js"></script>
<script src="http://cdn.bootcss.com/angular.js/1.3.17/angular.min.js"></script>
<script src="http://cdn.bootcss.com/lodash.js/3.10.1/lodash.js"></script>
<script src="../dist/ng-echarts.js"></script>
<script>
    angular.module('app',['ng-echarts'])
            .controller('MainCtrl', function ($scope,$timeout) {
                var opt = {
                    title : {
                        text: '未来一周气温变化(5秒后自动轮询)',
                        subtext: '纯属虚构'
                    },
                    tooltip : {
                        trigger: 'axis'
                    },
                    legend: {
                        data:['最高气温','最低气温']
                    },
                    toolbox: {
                        show : true,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {show: true, type: ['line', 'bar']},
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : true,
                    xAxis : [
                        {
                            type : 'category',
                            boundaryGap : false,
                            data : ['周一','周二','周三','周四','周五','周六','周日']
                        }
                    ],
                    yAxis : [
                        {
                            type : 'value',
                            axisLabel : {
                                formatter: '{value} °C'
                            }
                        }
                    ],
                    series : [
                        {
                            name:'最高气温',
                            type:'line',
                            data:[11, 11, 15, 13, 12, 13, 10],
                            markPoint : {
                                data : [
                                    {type : 'max', name: '最大值'},
                                    {type : 'min', name: '最小值'}
                                ]
                            },
                            markLine : {
                                data : [
                                    {type : 'average', name: '平均值'}
                                ]
                            }
                        },
                        {
                            name:'最低气温',
                            type:'line',
                            data:[1, -2, 2, 5, 3, 2, 0],
                            markPoint : {
                                data : [
                                    {name : '周最低', value : -2, xAxis: 1, yAxis: -1.5}
                                ]
                            },
                            markLine : {
                                data : [
                                    {type : 'average', name : '平均值'}
                                ]
                            }
                        }
                    ]
                };

                var setting = {
                    dataLoaded: false,
//                        loadingOption: {
//                            text : '数据加载中...',
//                            effect : 'bubble',
//                            textStyle : {
//                                fontSize : 40
//                            }
//                        },
                    event: [{click:onClick}],
                    option: {}
                };

                function onClick(params){
                    alert(params.name);
                };

                $scope.setting = setting;

                $timeout(function () {
                    $scope.setting.option = opt;
                    $scope.setting.dataLoaded = true;

                },2000);

            });
</script>
</body>
</html>